package com.billow.book.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.billow.book.mapper.BookMapper;
import com.billow.book.model.Book;
import com.billow.book.model.vo.BookVo;
import com.billow.book.service.BookService;
import org.springframework.stereotype.Service;

@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {

    @Override
    public Page<Book> findPageBook(long pageSize, long pageNo, BookVo bookVo) {
        Page<Book> bookPage = this.lambdaQuery()
                .like(StrUtil.isNotBlank(bookVo.getName()), Book::getName, bookVo.getName())
                .like(StrUtil.isNotBlank(bookVo.getAuthor()), Book::getAuthor, bookVo.getAuthor())
                .page(Page.of(pageNo, pageSize));
        return bookPage;
    }
}
